<!doctype html>
<html class="no-js fixed-layout">
<head>
    <!-- 公共head Begin -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="keywords" content="萌宠之家-C2B2C社会化电商平台" />
    <meta name="description" content="《萌宠之家-C2B2C社会化电商平台》是一个基于宠物社区的一站式电商平台。" />
    <meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1.0, maximum-scale=1.0">

    <title>萌宠之家-C2B2C社会化电商平台->运营后台</title>

    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">

    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <link rel="icon" type="image/png" href="../statics/img/favicon.png">

    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
    <link rel="icon" sizes="192x192" href="../statics/img/app-icon72x72@2x.png">

    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Pet Mall"/>
    <link rel="apple-touch-icon-precomposed" href="../statics/img/app-icon72x72@2x.png">

    <!-- Tile icon for Win8 (144x144 + tile color) -->
    <meta name="msapplication-TileImage" content="../statics/img/app-icon72x72@2x.png">
    <meta name="msapplication-TileColor" content="#0e90d2">

    <link rel="stylesheet" href="../statics/AmazeUI/assets/css/amazeui.min.css">
    <link rel="stylesheet" href="../statics/AmazeUI/assets/css/admin.css">
    <link rel="stylesheet" href="../statics/AmazeUI/assets/css/app.css">

    <!--[if (gte IE 9)|!(IE)]><!-->
    <script src="../statics/AmazeUI/assets/js/jquery.min.js"></script>
    <!--<![endif]-->
    <script src="../statics/AmazeUI/assets/js/amazeui.min.js"></script>
    <script src="../statics/AmazeUI/assets/js/amazeui.modal.js"></script>
    <script src="../statics/js/list.js"></script>
    <!-- 百度编辑器
    <script type="text/javascript" charset="utf-8" src="../statics/UEditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="../statics/UEditor/ueditor.all.min.js"></script>
    <script type="text/javascript" charset="utf-8" src="../statics/UEditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript">
        var ue = UE.getEditor('editor',{
                initialFrameWidth:"100%" //初始化选项
                //scaleEnabled:true//scaleEnabled {Boolean} [默认值：false] //是否可以拉伸长高，默认true(当开启时，自动长高失效)
            }
        );
    </script>
     -->
    <script src="../statics/AmazeUI/assets/js/validator.js"></script>
    <script src="../statics/js/plugin/jquery.livequery.js"></script>
    <!-- 此处form的导入和amazeui.min.js会有冲突 -->
    <script src="../statics/js/plugin/jquery.form.js"></script>

    <!--
    <script>
        $().ready( function() {
            AMUI.plugin('mySelected', AMUI.selected);
            $('[data-am-selected]').mySelected({btnWidth: '100%', maxHeight: '200px', btnSize: 'sm', btnStyle: 'secondary'});
        });
    </script>
        -->
    <script src="../statics/js/plugin/jquery.metadata.js"></script>
    <script src="../statics/js/base.js"></script>
    <script src="../statics/js/jquery.lSelect.js"></script>

    <!-- 公共head End -->
</head>
<body>
<div class="header">
    <div class="am-g am-text-center am-margin-top">
        <h1>《萌宠之家》后台管理</h1>
    </div>
    <hr class="am-margin-top-0" />
</div>
<div class="am-g">
    <div class="am-u-lg-6 am-u-md-8 am-u-sm-centered">
        <form id="loginForm" class="validator-form am-form am-form-horizontal" callback="loginFormAjaxSubmit()" action="http://localhost:8080/user/login" method="post">
            <div class="am-form-group">
                <label for="username" class="am-u-sm-3 am-form-label">用户名</label>
                <div class="am-u-sm-9">
                    <input type="text" name="username" id="username" placeholder="用户名/邮箱" data-validation-message="请输入正确的用户名" minlength="2" maxlength="20" pattern="^([0-9a-z_A-Z\u4e00-\u9fa5]+)$" required />
                </div>
            </div>

            <div class="am-form-group">
                <label for="passward" class="am-u-sm-3 am-form-label">密码</label>
                <div class="am-u-sm-9">
                    <input type="password" name="password" id="passward" placeholder="密码" data-validation-message="请输入正确的密码" required />
                </div>
            </div>

            <div class="am-form-group">
                <div class="am-u-sm-12 am-u-md-9 am-u-md-offset-3">
                    <input type="hidden" name="role" value="2" />
                    <button type="submit" class="am-btn am-btn-primary am-btn-block">登 录</button>
                </div>
            </div>
        </form>
    </div>
</div>
<!-- 弹出框 Begin -->
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">提示</div>
        <div class="am-modal-bd">
            <span id="lblMsg"></span>
        </div>
        <div class="am-modal-footer">
            <span class="am-modal-btn">确定</span>
        </div>
    </div>
</div>
<!-- 弹出框 End -->

<script>
    $(function() {

        if (self.location != top.location)
            top.location.href = 'admin_center.html';

    });//  $(function());

    /** '登录表单' Ajax提交 **/
    function loginFormAjaxSubmit(){

        // '登录表单'提交
        $("#loginForm").ajaxSubmit({
            success:function(result){

                // 如果返回的数据的响应码不是'成功(200)'
                if(result.code != 200) {
                    $('#lblMsg').text(result.msg);
                    $('#my-alert').modal('open');
                    return;
                }

                // 如果返回的数据响应码为200
                // 将返回的token信息存入到客户端session中
                sessionStorage.setItem( "token", result.token );
                // 将放回的用户信息存入到客户端session中
                sessionStorage.setItem( "admin", JSON.stringify(result.data) );
                // 跳转到后台首页
                window.location.href="admin_center.html";

            }// success(result);
        });

    }// loginFormAjaxSubmit();
</script>
</body>
</html>